<template>
  <div class="setting-app-container">
    <div class="applet-blendent-header">设置合伙人基本信息</div>
    <div style="margin:15px"></div>
    <el-form :model="setData" ref="addform" label-width="160px" size="small">
      <el-form-item label="开启合伙人">
        <el-switch v-model="setData.open_partner" active-color="#13ce66" active-value="1" inactive-value="0"></el-switch>
      </el-form-item>
      <el-form-item label="提现手续费">
        <el-input v-model="setData.partner_handling_fee" placeholder="请输入" style="width: 20%"/>
      </el-form-item>
    </el-form>

    <div style="text-align:center">
      <el-button type="primary" size="small" style="padding:8px 30px;" @click="submit">提 交</el-button>
    </div>
  </div>
</template>

<script>
import { getPartnerSetting, postPartnerSetting } from '@/api/partner'

export default {
  name: 'partner-setting',
  data() {
    return {
      setData: {}
    }
  },
  mounted() {
    this.getPartnerSetting();
  },
  methods: {
    /**
     * 获取合伙人设置信息
     */
    getPartnerSetting() {
      getPartnerSetting({id: this.$store.state.app.activeApp.saa_id, key: this.$store.state.app.activeApp.saa_key}).then(res => {
        if(res.status === 200) {
          this.setData = res.data;
        }else{
          this.$message.error(res.message);
        }
      })
    },
    submit() {
      const params = {
        open_partner: this.setData.open_partner,
        partner_handling_fee: this.setData.partner_handling_fee,
        key: this.$store.state.app.activeApp.saa_key
      }
      postPartnerSetting(params).then(res => {
        if(res.status === 200) {
          this.$message.success('修改成功！');
        }else{
          this.$message.error(res.message);
        }
      })
    }
  },
}
</script>

<style lang="scss" scoped>
.setting-app-container{
  min-height: calc(100vh - 100px);
  margin: 20px;
  background-color: #fff;
  padding:25px;
  box-shadow: 0px 0px 4px 0px rgba(115, 115, 115, 0.2);
}
.applet-blendent-header{
  height: 40px;
  width: 100%;
  line-height: 40px;
  font-size: 16px; 
  font-weight: 600;
  letter-spacing: 2px;
  color: #8f8f8f;
  padding: 0 10px;
  background-color: #F4F8FB;
}
</style>